<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="checkbox" name="checkItem" />JAVA
    <input type="checkbox" name="checkItem" />C++
    <input type="checkbox" name="checkItem" />Python
    <input type="checkbox" name="checkItem" />PHP
    <hr />
    <input type="checkbox" id="checkAll" />全选/全不选

    <script src="jquery/jquery-3.6.1.js" type="text/javascript"></script>

    <script>
      let items = $("[name=checkItem]");
      let all = $("#checkAll");
      items.click(() => {
        for (obj of items) {
          console.log(obj);
        }
      });

      all.on("click", () => {
        items.attr("checked", all.prop("checked"));
      });
    </script>
  </body>
</html>
